{% set page_name = "发放记录" %}
{% import "components/paginator.html" as paginator with context %}
{% import "components/nothing.html" as nothing with context %}
{% extends "coin_base.html" %}
{% block coin_content %}
<div class="row">
  <div class="medium-12 columns">
    <div class="section">
      <div class="section__header">
        <h1 class="section__title">{% if udoc._id %}{{user.render_inline(udoc,badge=false) }}{% else %}{{ _('所有人') }}{% endif %}{{ _('的发放记录') }}</h1>
        <div class="section__tools">
              {% if udoc['coin_all'] > 0 %}
                当前硬币数量: {{ udoc['coin_now'] }} （累计获取硬币数量：{{ udoc['coin_all'] }}）
              {% endif %}
        </div>
      </div>
      <div class="section__body no-padding">
        <div data-fragment-id="ranking">
          {% if not bills.length %}
          {{ nothing.render('没有过硬币！') }}
          {% else %}
          <table class="data-table">
            <colgroup>
              <col class="col--time" style="width:8rem">
              <col class="col--uid">
              <col class="col--uid">
              <col class="col--amount" style="width:8rem">
              <col class="col--text" style="width:8rem">
            </colgroup>
            <thead>
              <tr>
                <th class="col--time">{{ _('Time') }}</th>
                <th class="col--uid">{{ _('发放者') }}</th>
                <th class="col--uid">{{ _('接收者') }}</th>
                <th class="col--amount">{{ _('数额') }}</th>
                <th class="col--text">{{ _('原因') }}</th>
              </tr>
            </thead>
            <tbody>
              {%- for bill in bills -%}
              <tr data-uid="{{ udoc.uid }}">
                <td class="col--time">{{ datetimeSpan(bill._id)|safe }}</td>
                <td class="col--uid">
    {% if handler.user.hasPerm(perm.PERM_VIEW_DISPLAYNAME) and users[bill.rootId].realname_name %}
      {{ users[bill.rootId].realname_name }} ({{ users[bill.rootId].uname }})
    {% elif handler.user.hasPerm(perm.PERM_VIEW_DISPLAYNAME) and users[bill.rootId].displayName and users[bill.rootId].displayName != users[bill.rootId].uname %}
      {{ users[bill.rootId].displayName }} ({{ users[bill.rootId].uname }})
    {% else %}
      {{ users[bill.rootId].uname }}
    {% endif %}
 </td>
                <td class="col--uid"><a href="{{ url('coin_bill') }}?uid={{ bill.userId }}">
    {% if handler.user.hasPerm(perm.PERM_VIEW_DISPLAYNAME) and users[bill.userId].realname_name %}
      {{ users[bill.userId].realname_name }} ({{ users[bill.userId].uname }})
    {% elif handler.user.hasPerm(perm.PERM_VIEW_DISPLAYNAME) and users[bill.userId].displayName and users[bill.userId].displayName != users[bill.userId].uname %}
      {{ users[bill.userId].displayName }} ({{ users[bill.userId].uname }})
    {% else %}
      {{ users[bill.userId].uname }}
    {% endif %}
 </a></td>
                <td class="col--amount">{{ bill.amount }}</td>
                <td class="col--text">{{ bill.text }}</td>
              </tr>
              {%- endfor -%}
            </tbody>
          </table>
	  {{ paginator.render(page, upcount,add_qs=('uid=' + udoc._id)) }}	
	  {% endif %}
        </div>
      </div>
    </div>
  </div>
</div>
{% endblock %}
